package com.guoxin.chapter1;

import java.util.concurrent.TimeUnit;

/**
 * 执行start()方法的顺序不代表线程启动的顺序
 *
 * @author guoxin
 * @date 2019/8/8
 */
public class UnorderlyThread {

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(new MyThread(i)).start();
        }
    }

    private static class MyThread implements Runnable {
        private int num;

        MyThread(int num) {
            this.num = num;
        }

        @Override
        public void run() {
            try {
                TimeUnit.MILLISECONDS.sleep(100);
                System.out.println(num);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
